package com.fanpan26.thread.print;

/**
 * @author fanpan26
 */
public class RunLoopPrintB implements Runnable {

    private final Printer printer ;

    public RunLoopPrintB(Printer printer){
        this.printer = printer;
    }

    /**
     * When an object implementing interface <code>Runnable</code> is used
     * to create a thread, starting the thread causes the object's
     * <code>run</code> method to be called in that separately executing
     * thread.
     * <p>
     * The general contract of the method <code>run</code> is that it may
     * take any action whatsoever.
     *
     * @see Thread#run()
     */
    @Override
    public void run() {
        for (int i=0;i<100;i++){
            try {
                printer.printB();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
